<template>
  <div>
    <el-tree
      :data="data"
      :props="defaultProps"
      accordion
      @node-click="handleNodeClick"
      default-expand-all
      class="organTree"
      :style="{ height: scrollerHeight, overflow: 'auto', }"
    >
    </el-tree>
  </div>
</template>

<script>
import { getcoreorgList } from "@/api/coreorg.js";
import router from "../../router";
import {selectshuju} from "../../api/dispatch";
export default {
  data() {
    return {
      name: "",
      data: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
    };
  },

  mounted() {
    this.getcoreorg();
  },

  methods: {
    getcoreorg(name) {
      let parmas = {
        "name": this.name = name
      }
      getcoreorgList(parmas).then(({ data }) => {
        this.data = data.page;
      });
    },

    handleNodeClick(e) {

     let coid = e.id;


      selectshuju(coid).then(({ data }) => {
        let coname = e.name
        let params = {
          'data': data,
          'coname':coname,
          'coid':coid
        }

        this.bus.$emit('handleNodeClick',params)

      });
    },
  },
  computed: {
    scrollerHeight() {
      return window.innerHeight - 200 + "px";
    },
  },
};
</script>

<style  scoped>
.organTree::-webkit-scrollbar {
  display: none;
}
</style>
